﻿//
//  Manyou.Toolkit.ManyouException.cs:
//  Authors:
//	Bryan Chow (cabir.zhou@gmail.com)
//
//
//  No Trademark License- This license does not grant you rights to use any 
//  contributors' name, logo, or trademarks.
//
//  If you bring a patent claim against any contributor over patents that you
//  claim are infringed by the software, your patent license from such 
//  contributor to the software ends automatically.
//
//  If you distribute any portion of the software, you must retain
//  all copyright, patent, trademark, and attribution notices that are present in the software.
//
//  If you distribute any portion of the software in source code form,
//  you may do so only under this license by including a complete copy of this license
//  with your distribution. If you distribute any portion of the software
//  in compiled or object code form, you may only do so under a license that complies with this license.
//
//  The software is licensed "as-is." You bear the risk of using it. 
//  The contributors give no express warranties, guarantees or conditions.
//  You may have additional consumer rights under your local laws which 
//  this license cannot change. To the extent permitted under your local laws,
//  the contributors exclude the implied warranties of merchantability,
//  fitness for a particular purpose and non-infringement.
//

using System;
using System.Collections.Generic;
using System.Text;

namespace Manyou.Toolkit
{
    /// <summary>
    /// Discuz异常类
    /// </summary>
    public class ManyouException : Exception
    {
        private int error_code;
        private string error_message;

        /// <summary>
        /// 获取异常代码
        /// </summary>
        public int ErrorCode
        {
            get { return error_code; }
        }

        /// <summary>
        /// 获取异常描述
        /// </summary>
        public string ErrorMessage
        {
            get { return error_message; }
        }

        /// <summary>
        /// Discuz错误异常
        /// </summary>
        /// <param name="error_code">异常错误代码</param>
        /// <param name="error_message">异常描述</param>
        public ManyouException(int error_code, string error_message)
            : base(CreateMessage(error_code, error_message))
        {
            this.error_code = error_code;
            this.error_message = error_message;
        }

        /// <summary>
        /// 生成异常信息
        /// </summary>
        /// <param name="error_code">异常错误代码</param>
        /// <param name="error_message">异常描述</param>
        /// <returns>异常信息</returns>
        private static string CreateMessage(int error_code, string error_message)
        {
            return string.Format("Code: {0}, Message: {1}", error_code, error_message);
        }
    }
}
